﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Net;
using System.Net.Mail;
using System.IO;

namespace AngelPerez.Taringa.PostEdit {
	public class App {
		private static string[] _allowedIdentities = new string[] {
			"Angel@5736Z",
			"pozimi@pozimi-pc",
			"pozimi@pozimi-notebook",
			"Gaston@Gaston-PC"
		};

		public static bool PerformAlphaCheck() {
			foreach (string identity in _allowedIdentities) {
				if ((Environment.UserName + "@" + Environment.UserDomainName).ToLower() == identity.ToLower()) {
					return true;
				}
			}

			Application.ExitThread();
			Process.GetCurrentProcess().Kill();

			return false;
		}

		[STAThread]
		public static void Main() {
			try {
				PerformAlphaCheck();
			} catch {
				Application.ExitThread();
				Process.GetCurrentProcess().Kill();
			}

#if !DEBUG
			try {
#endif
				Application.EnableVisualStyles();
				Application.SetCompatibleTextRenderingDefault(false);
#if !DEBUG
				Application.SetUnhandledExceptionMode(UnhandledExceptionMode.Automatic);
				AppDomain.CurrentDomain.FirstChanceException += (sender, args) => {
					HandleFatalException(args.Exception);
				};
#endif
				Application.Run(new MainWindow());
#if !DEBUG
			} catch (Exception exception) {
				HandleFatalException(exception);
			}
#endif
		}

		private static void HandleFatalException(Exception exception) {
#if DEBUG
			throw exception;
#endif
		}
	}
}